option (USE_INTERNAL_GFLAGS_LIBRARY "Set to FALSE to use system gflags instead of bundled" ${NOT_UNBUNDLED})
if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/gflags/CMakeLists.txt")
   if (USE_INTERNAL_GFLAGS_LIBRARY)
       message (WARNING "submodule contrib/gflags is missing. to fix try run: \n git submodule update --init --recursive")
   endif ()
   set (USE_INTERNAL_GFLAGS_LIBRARY 0)
   set (MISSING_INTERNAL_GFLAGS_LIBRARY 1)
endif ()
if (NOT USE_INTERNAL_GFLAGS_LIBRARY)
    find_package(gflags)
endif ()
if (NOT GFLAGS_INCLUDE_PATH AND NOT MISSING_INTERNAL_GFLAGS_LIBRARY)
    set (USE_INTERNAL_GFLAGS_LIBRARY 1)
    set (GFLAGS_LIBRARY gflags::gflags)
    set (GFLAGS_INCLUDE_PATH "${ClickHouse_BINARY_DIR}/contrib/gflags/include")
endif ()
message (STATUS "Using gflags: ${GFLAGS_INCLUDE_PATH} : ${GFLAGS_LIBRARY}")